package com.atguigu.字符串操作;

import java.util.Scanner;

public class HJ33整数与IP地址间的转换 {

    private static int N=4;
    public static String convert(String str){
        //ip4->int
        if(str.contains(".")){
            String[] fields=str.split("\\.");
            long result=0;
            for(int i=0;i<N;i++){
                result=result*256+Integer.parseInt(fields[i]);
            }
            return ""+result;
        } //int -> ipv4
        else{
            long ipv4=Long.parseLong(str);
            String result="";
            for(int i=0;i<N;i++){
                result=ipv4%256+"."+result;
                ipv4=ipv4/256;
            }
            return result.substring(0,result.length()-1);
        }
    }
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        while(scanner.hasNext()){
            String str=scanner.nextLine();
            System.out.println(convert(str));
        }
    }
}
